﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Web;
using Microsoft.AspNetCore.Mvc;
using YiSha.Util;
using YiSha.Util.Model;
using YiSha.Entity;
using YiSha.Model;
using YiSha.Admin.Web.Controllers;
using YiSha.Entity.QixingManage;
using YiSha.Business.QixingManage;
using YiSha.Model.Param.QixingManage;

namespace YiSha.Admin.Web.Areas.QixingManage.Controllers
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2024-03-23 13:44
    /// 描 述：商品属性颜色控制器类
    /// </summary>
    [Area("QixingManage")]
    public class GoodsAttrController :  BaseController
    {
        private GoodsAttrBLL goodsAttrBLL = new GoodsAttrBLL();

        #region 视图功能
        [AuthorizeFilter("qixing:goodsattr:view")]
        public ActionResult GoodsAttrIndex()
        {
            return View();
        }

        public ActionResult GoodsAttrForm()
        {
            return View();
        }
        #endregion

        #region 获取数据
        [HttpGet]
        [AuthorizeFilter("qixing:goodsattr:search")]
        public async Task<ActionResult> GetListJson(GoodsAttrListParam param)
        {
            TData<List<GoodsAttrEntity>> obj = await goodsAttrBLL.GetList(param);
            return Json(obj);
        }

        [HttpGet]
        [AuthorizeFilter("qixing:goodsattr:search")]
        public async Task<ActionResult> GetPageListJson(GoodsAttrListParam param, Pagination pagination)
        {
            TData<List<GoodsAttrEntity>> obj = await goodsAttrBLL.GetPageList(param, pagination);
            return Json(obj);
        }

        [HttpGet]
        public async Task<ActionResult> GetFormJson(long id)
        {
            TData<GoodsAttrEntity> obj = await goodsAttrBLL.GetEntity(id);
            return Json(obj);
        }
        #endregion

        #region 提交数据
        [HttpPost]
        [AuthorizeFilter("qixing:goodsattr:add,qixing:goodsattr:edit")]
        public async Task<ActionResult> SaveFormJson(GoodsAttrEntity entity)
        {
            TData<string> obj = await goodsAttrBLL.SaveForm(entity);
            return Json(obj);
        }

        [HttpPost]
        [AuthorizeFilter("qixing:goodsattr:delete")]
        public async Task<ActionResult> DeleteFormJson(string ids)
        {
            TData obj = await goodsAttrBLL.DeleteForm(ids);
            return Json(obj);
        }

        [HttpPost]
        [AuthorizeFilter("qixing:goodsattr:add")]
        public async Task<ActionResult> TBFormJson()
        {
            TData obj = await goodsAttrBLL.TBFormJson();
            return Json(obj);
        }
        #endregion
    }
}
